package com.example.shuma_product.controller;

import com.example.shuma_product.dto.rep.ManagerLoginReqDTO;
import com.example.shuma_product.dto.rep.ManagerRegisterRepDTO;
import com.example.shuma_product.dto.resp.ManagerLoginRespDTO;
import com.example.shuma_product.result.Result;
import com.example.shuma_product.result.Results;
import com.example.shuma_product.service.ManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ManagerController {

    @Autowired
    private ManagerService managerService;

    /**
     * 管理员注册
     * @param requestParam
     * @return
     */
    @PostMapping("/user/register")
    public Result<Void> register(@RequestBody ManagerRegisterRepDTO requestParam){
        managerService.register(requestParam);
        return Results.success();
    }

    /**
     * 管理员登录
     * @param requestParam
     * @return
     */
    @PostMapping("/user/login")
    public Result<ManagerLoginRespDTO> login(@RequestBody ManagerLoginReqDTO requestParam){
        ManagerLoginRespDTO result = managerService.login(requestParam);
        return Results.success(result);
    }
}
